// Chat View

PANEL = {}
PANEL.Text = ""
PANEL.Delim = ""
PANEL.Trim = 0
function PANEL:SetChatText( text, delim )
	self.Text = text
	self.Delim = delim
	if (self.Text == "") then return end
	local txt = string.Explode( "#", self.Text )
	if ((#txt*20) > self:GetTall()) then
		self.Trim = ((#txt*20)-self:GetTall())/20
	end
end
function PANEL:Paint()
	// Draw background
	draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 255, 255, 255, 200 ) )
	
	// Draw text
	if (self.Text == "") then return end
	local txt = string.Explode( "#", self.Text )
	local cnt = 0
	for k, v in pairs( txt ) do
		if (k > self.Trim) then
			cnt = cnt + 1
			local x = 5
			local y = ((cnt-1)*20) + 5
			local fontname = "PCText"
			if (string.sub( v, 1, 3 ) == "[b]") then
				fontname = "PCTextBold"
				v = string.sub( v, 4 )
			end
			draw.SimpleText( v, fontname, x, y, Color( 0, 0, 0, 255 ), TEXT_ALIGN_TOP, TEXT_ALIGN_LEFT )
		end
	end
end
vgui.Register( "ChatView", PANEL, "PANEL" )